Skip to content

Conversation

@elabpro
Copy link
Contributor

@elabpro elabpro commented Oct 10, 2025

  1. Inventory as plugin (for future needs)
  2. Fix for domain name in 2DC configuration
  3. More checks
  4. Move ydb as user/group names into variables for more flexibility.
  5. Disable healthcheck for YDB 25.* (until HC will be fixed for 3-nodes-mirror-3-dc)
  6. Clean up for variables (removed new variables for V2)

@elabpro elabpro requested a review from VadimZud October 10, 2025 06:40
@elabpro elabpro changed the title YDBOPS-12647: Database quotas YDBOPS-12647: New inventory and some fixes Oct 13, 2025

self.inventory.groups['ydb'].set_variable('ydb_config_dict', yaml_config)

if 'ydb_dbname' not in ydb_vars and 'ydb_dynnodes' in ydb_vars:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Кажется здесь плагин решает какую-то проблему определения дефолтов, которую inventory плагин не должен решать. Для этого у ansible есть другие механизмы. Особенно учитывая, что конфиг никак не используется для определения этих дефолтов

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А вот здесь возникает интересная проблема:

  • inventory плагин анализирует config.yaml и, в частности, сопоставляет диски хостам
  • в inventory.yaml файле прописывается соответствие дисков label-ам
  • если плагин запускать до загрузки inventory.yaml, то у нас не будет распределения дисков с лейблами по хостам, либо надо делать еще один плагин, который будет срабатывать после парсинга инвентори, те надо будет 3 файла уже в каталоге inventory

можно расширить config.yaml и в него тогда внести описание дисковых лейблов, но это будет дополнительные поля, на которые будет ругаться парсер YDB, либо надо уходить от лейблов

лучше, на мой взгляд, оставить так как сейчас реализовано

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

изменено поведение

become: true
shell: dd if=/dev/zero of={{ item.name }} bs=1M count=100 status=none
loop: "{{ ydb_disks }}"
shell: dd if=/dev/zero of={{ item.name | default(ydb_disks|selectattr('label','match',item.label)|map(attribute='name')|join()) }} bs=1M count=100 status=none
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Свалится с неочевидной для пользователя ошибкой, если в ydb_disks нет диска с лейблом ydb_drives[x].label.
Будет попытка запустить dd if=/dev/zero of= bs=1M count=100 status=none

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добавлена проверка дисков

become: true
shell: dd if=/dev/zero of={{ item.name }} bs=1M count=100 status=none
loop: "{{ ydb_disks }}"
shell: dd if=/dev/zero of={{ item.name | default(ydb_disks|selectattr('label','match',item.label)|map(attribute='name')|join()) }} bs=1M count=100 status=none
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Свалится с неочевидной для пользователя ошибкой, если в ydb_disks нет диска с лейблом ydb_drives[x].label.
Будет попытка запустить dd if=/dev/zero of= bs=1M count=100 status=none

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добавлена проверка дисков

DOCUMENTATION = r'''
name: yaml_filters
plugin_type: filter
short_description: short desc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Эти описания-заглушки здесь ожидаемы?

self.inventory.add_group(group_name)
brokers = []

ydb_vars = self.inventory.groups[group_name].get_vars()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Идея была никак не полагаться на состояние переменных в момент вызова плагина.
Первая же идея, как такое сломается: пользователь разбирается в ansible и захочет определить для отдельного хоста или подмножествва хостов свои ydb_disks.
В этом плагине ты потеряешь эти настройки пользователя.
Что будет, если в момент вызова плагина еще не успели определиться какие-то переменные?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Изменено поведение плагина

drive_configs = {}
drive_labels = {}

if 'ydb_disks' in ydb_vars:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Идея была никак не полагаться на состояние переменных в момент вызова плагина.
Первая же идея, как такое сломается: пользователь разбирается в ansible и захочет определить для отдельного хоста или подмножествва хостов свои ydb_disks.
В этом плагине ты потеряешь эти настройки пользователя.
Что будет, если в момент вызова плагина еще не успела определиться ydb_disks?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Изменено поведение плагина

for drive_config in yaml_config['host_configs']:
drive_configs[drive_config['host_config_id']] = copy.deepcopy(drive_config['drive'])
for i, item in enumerate(drive_config['drive']):
label = item['path'].split('/')[-1]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Что делать, если пользователь инвентори не хочет пользоваться метками, а использовать другие механизмы обеспечения стабильных имен дисков? Что делать, если последний компонент пути диска не является лейблом?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добавлена проверка дисков, которая учитывает эти моменты

env:
- name: INVENTORY_YDB_CONFIG
ydb_hostgroup_name:
description: The name of group of hosts (default name is 'ydb')
Copy link
Contributor

@VadimZud VadimZud Oct 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нужно написать значение по умолчанию в отдельное поле default.
При этом, кажется, не придется определять его в коде, self.get_option('ydb_hostgroup_name') должен автоматически вернуть дефолт из документации, если пользователь не определил параметр (стоит перепроверить)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Доработано описание

ydb_platform.ydb.drive_prepare:
name: "{{ item['name'] }}"
name: "{{ item.name | default(ydb_disks|selectattr('label','match',item.label)|map(attribute='name')|join()) }}"
label: "{{ item['label'] }}"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В этом месте пустое значение допустимо, так как модуль drive_prepare сделает проверку и вылетит с ошибкой, если такое встретит

@elabpro elabpro merged commit 4e70bf4 into ydb-platform:main Nov 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants